Skip to content

feat(mcp): add Windows support for code search via PowerShell#310

Merged
DeusData merged 2 commits intoDeusData:mainfrom
noctrex:feat/windows-support
May 10, 2026
Merged

feat(mcp): add Windows support for code search via PowerShell#310
DeusData merged 2 commits intoDeusData:mainfrom
noctrex:feat/windows-support

Conversation

@noctrex
Copy link
Copy Markdown
Contributor

@noctrex noctrex commented May 1, 2026

Replace grep with PowerShell Select-String on Windows for the search_code and search_graph tools, enabling cross-platform functionality.

  • Use tab-delimited output from Select-String to avoid conflicts with colons in Windows drive-letter paths (e.g. C:\dir\file).
  • Update collect_grep_matches to parse delimiter as tab on Windows and colon on POSIX.
  • Open scoped filelist in binary mode ("wb") and use forward slashes on Windows to prevent xargs from interpreting backslashes as escape sequences.
  • Use cbm_tmpdir() for pattern temp files instead of hardcoded /tmp/.
  • Define getpid as _getpid on Windows for consistent API.

Fixes #196

@DeusData DeusData added enhancement New feature or request windows Windows-specific issues labels May 4, 2026
@arkiaman
Copy link
Copy Markdown

arkiaman commented May 8, 2026

see #326 for additional context

@DeusData DeusData merged commit 82a9052 into DeusData:main May 10, 2026
@DeusData
Copy link
Copy Markdown
Owner

Merged via rebase, thanks @noctrex. The PowerShell Select-String swap is well-scoped — #ifdef _WIN32 keeps the POSIX path untouched, the tab-vs-colon delimiter switch is the right move (Windows paths legitimately contain : after the drive letter), and pivoting to cbm_tmpdir() for the pattern temp file is a solid cleanup that drops the hardcoded /tmp/. The forward-slash filelist + binary-mode write closes the xargs-backslash-as-escape gotcha cleanly. Issue #196 should be resolved.

One follow-up landed on main directly (eca433b): cbm_validate_shell_arg now also blocks ", <, >. The PR's PowerShell command is wrapped at the cmd.exe level (powershell -Command "..."), so a " in file_pattern could close that outer quote even when the inner PowerShell single quotes hold; with < > unblocked, that opened a cmd.exe redirection primitive. Existing blocking of ' ; | & $ \`` already prevents RCE, so this is hardening rather than a fix for an exploitable RCE in this PR — but worth tightening since the new code path made the validator load-bearing in a new shell context. Three tests added in tests/test_security.c`.

Nice contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request windows Windows-specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli search_code returns "search failed: temp file" on Windows 11 in Powershell

3 participants